package com.dog.basics.common.photooss.configuration;


import com.dog.basics.common.photooss.properties.QiniuOSSProperties;
import com.dog.basics.common.photooss.service.PhotoOssUtil;
import com.dog.basics.common.photooss.service.impl.QiniuPhotoOssUtil;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program: baby_singing_together
 *
 * @description: 判断是否七牛云
 *
 * @author: Guo
 *
 * @create: 2020-02-15 09:38
 **/
@AllArgsConstructor
@Configuration
@ConditionalOnClass(PhotoOssUtil.class)
@EnableConfigurationProperties({QiniuOSSProperties.class})
@ConditionalOnProperty(name = "flag", havingValue = "true")

public class QiniuPhotoConfiguration {

	private final QiniuOSSProperties qiniuOSSProperties;


	/**
	 * Bean 阿里云OSS上传
	 * @return
	 */
	@Bean
	//@ConditionalOnProperty(name = "photo-oss.component", havingValue = "QiniuOSS")
	PhotoOssUtil qiniuPhotoOssUtil() {
		QiniuPhotoOssUtil qiniuPhotoOssUtil = new QiniuPhotoOssUtil(qiniuOSSProperties);
		return qiniuPhotoOssUtil;
	}

}
